<template>
  <div class="components-board-entry-row-list">
    <div
      v-for="(item, index) in list"
      :key="index"
      :style="itemWidth"
      class="entry-item"
      @click.stop="handleItem(item)"
    >
      <div class="icon_wrp">
        <i :class="`${item.icon}`"></i>
      </div>
      <p class="label">{{ item.label }}</p>
    </div>
  </div>
</template>
<script>
export default {
  name: 'Index',
  props: {
    list: {
      type: Array,
      default: () => {},
    },
  },
  computed: {
    itemWidth() {
      if (this.list.length < 1) return { width: 'auto' };
      return { width: `${100 / this.list.length}%` };
    },
  },
  methods: {
    handleItem(item) {
      if (!item.code) {
        return JE.alert('该功能暂未开发完成，敬请期待');
      }
      this.$emit('click', item);
    },
  },
};
</script>

<style lang="less" scoped>
  .components-board-entry-row-list {
    background: #ffffff;
    padding: 15px 0;
    > .entry-item {
      float: left;
      position: relative;
      cursor: pointer;
      .icon_wrp {
        width: 48px;
        height: 48px;
        margin: 0 auto 5px;
        position: relative;
        border: 1px solid #4094ED;
        background: #4094ED;
        border-color: #4094ED;
        color: #ffffff;
        border-radius: 5px;
        i {
          position: absolute;
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%);
          font-size: 20px;
        }
        
      }
      .label {
        text-align: center;
      }
      &:not(:first-child) {
        &:before {
          content: ' ';
          position: absolute;
          top: 15px;
          left: 0;
          bottom: 30px;
          background: #f0f2f5;
          width: 1px;
        }
      }
      &:hover {
        .icon_wrp {
          border-color: rgba(64, 148, 237, .3);
          background: rgba(64, 148, 237, .3);
          color: #4094ED;
        }
      }
    }
    &:after {
      content: '';
      display: table;
      clear: both;
    }
  }
</style>
